#include "ResourceManager.h"

ResourceManager* ResourceManager::_instance = NULL;

ResourceManager* ResourceManager::GetInst()
{
	if(ResourceManager::_instance == NULL)
	{
		_instance = new ResourceManager();
	}

	return _instance;
}

ResourceManager::ResourceManager()
{
	/// texture
	m_listFileName.push_back("Resource/texture/leo.jpg");
	m_listFileName.push_back("Resource/texture/eclipse.png");
	m_listFileName.push_back("Resource/texture/particle.png");

	m_listFileName.push_back("Resource/texture/Sky Box/front.png");
	m_listFileName.push_back("Resource/texture/Sky Box/back.png");
	m_listFileName.push_back("Resource/texture/Sky Box/top.png");
	m_listFileName.push_back("Resource/texture/Sky Box/bottom.png");
	m_listFileName.push_back("Resource/texture/Sky Box/left.png");
	m_listFileName.push_back("Resource/texture/Sky Box/right.png");

	/// background

	m_listFileName.push_back("Resource/Image/Box_Plane.png");
	m_listFileName.push_back("Resource/Image/Box_Wall.png");
	m_listFileName.push_back("Resource/Image/BG_About.png");
	m_listFileName.push_back("Resource/Image/BG_MainMenu.png");

	/// large button
	m_listFileName.push_back("Resource/Image/BT_About.png");
	m_listFileName.push_back("Resource/Image/BT_Play.png");
	m_listFileName.push_back("Resource/Image/BT_Quit.png");

	/// quick launce button
	m_listFileName.push_back("Resource/Image/SBT_MainMenu.png");
	m_listFileName.push_back("Resource/Image/SBT_MusicOff.png");
	m_listFileName.push_back("Resource/Image/SBT_MusicOn.png");
	m_listFileName.push_back("Resource/Image/SBT_Replay.png");
	m_listFileName.push_back("Resource/Image/SBT_Help.png");

	/// Number sprite
	m_listFileName.push_back("Resource/Image/SP_Number.png");

	/// Popup
	m_listFileName.push_back("Resource/Image/BG_Win.png");
	m_listFileName.push_back("Resource/Image/BG_Lose.png");
	m_listFileName.push_back("Resource/Image/PU_ComputerTurn.png");
	m_listFileName.push_back("Resource/Image/PU_PlayerTurn.png");
	m_listFileName.push_back("Resource/Image/PU_Help.png");
	
	texture = new UINT[m_listFileName.size()];
	for(int i = 0; i< m_listFileName.size(); i++)
	{
		texture[i] = SOIL_load_OGL_texture
			(
			m_listFileName[i],
			SOIL_LOAD_AUTO,
			SOIL_CREATE_NEW_ID,
			SOIL_FLAG_INVERT_Y
			);
	}
}


ResourceManager::~ResourceManager(void)
{
}

void ResourceManager::LoadTexture(int ID)
{
	glBindTexture(GL_TEXTURE_2D, texture[ID]);
}

void ResourceManager::LoadTexture(char* _fileName)
{
	for(int i = 0; i< m_listFileName.size(); i++)
	{
		if(m_listFileName[i] == _fileName)
		
		glBindTexture(GL_TEXTURE_2D, texture[i]);
	}
	
	
}
